/**
 * 
 */
#ifndef CORE_SOURCES_IO_BASE_PACKET_BASE_H_
#define CORE_SOURCES_IO_BASE_PACKET_BASE_H_

#include "basic/object.hpp"
#include "buffer/iobuffer.h"

namespace eyas{
namespace io{

class packet_decoder_base{
public:
	packet_decoder_base() = default;
	virtual ~packet_decoder_base() = default;

public:
	virtual int32_t advance_recv_buffer() = 0;
	// 收到数据调用
	// return true:数据包完整  false:不完整
	virtual bool decode(eyas::buffer::iobuffer& buffer) = 0;
	// 数据
	virtual eyas::buffer::iobuffer& data() = 0;
};

class packet_encoder_base{
public:
	packet_encoder_base(){}// = default;
	virtual ~packet_encoder_base(){}// = default;

public:
	// 发送数据的缓冲区（发送其会一直调用该函数，直至advanceSize为0为止）
	virtual void encode(eyas::buffer::iobuffer& buffer) = 0;
};

}
}
#endif
